package com.boot2.core.scheduler;

import lombok.extern.apachecommons.CommonsLog;
import org.quartz.Job;
import org.quartz.JobExecutionContext;


/**
 * @author zhangweilin
 * @description:并发job
 * @date 2018/6/7
 */
@CommonsLog
public abstract class AbstractConcurrentJob implements Job,JobHandler {
    @Override
    public void execute(JobExecutionContext jobExecutionContext)  {
        //由子类执行，有逻辑在此补充
        run(jobExecutionContext);
    }

    protected void run(JobExecutionContext jobExecutionContext) {
        hand(jobExecutionContext);
        //将调度信息本身也实时入库
//        JobExecutionContextService jobExecutionContextService = SpringUtil.getBean(JobExecutionContextService.class);
//        jobExecutionContextService.saveJobExecutionContext(jobExecutionContext);

//        JobDataMap mergedJobDataMap = jobExecutionContext.getMergedJobDataMap();
//        String code = (String) mergedJobDataMap.get(SchedulerJobDataMapConsant.code);
//        try {
//            hand(jobExecutionContext);
//        } catch (Exception e) {
//            e.printStackTrace();
//            log.error("定时任务出错，code:"+code+"，更多细节:"+jobExecutionContext,e);
//        }
    }

}
